from tortoise.contrib.pydantic import pydantic_model_creator
from tortoise.models import Model
from tortoise import fields

class User(Model):
    id = fields.IntField(pk=True, description='用户ID')
    user = fields.CharField(max_length=50, description="账号")
    name = fields.CharField(max_length=50, description='用户名')
    hash_password = fields.CharField(max_length=128, description='密码')
    role = fields.CharField(max_length=50, description='角色')
    level = fields.IntField(default=0, description='等级')
    active = fields.BooleanField(default=True, description='是否登录')
    last_login = fields.DatetimeField(auto_now_add=True, description='最后上线时间')
    from_place = fields.CharField(max_length=50, description='来源')

User_Pydantic = pydantic_model_creator(User, name="User")